/*
    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

#ifndef TEXTUREMANAGER_H
#define TEXTUREMANAGER_H

#include "BaseTypes.h"
#include "Singleton.h"

#include <string>
#include <vector>

class Texture;
class TextureDescription;

enum textureType
{
   TEXTURE_CHARA = 0,
   TEXTURE_ME,
   NB_TEXTURE
};


class TextureManager : public Singleton<TextureManager>
{
   friend class Singleton<TextureManager>;

   protected :

      TextureManager();

      ~TextureManager();

   protected :

      struct TextureData
      {
         Texture            * _texture;
         TextureDescription * _descriptor;
      };

      
   protected :

      std::vector<TextureData *> _vTextures[NB_TEXTURE];

   public :

      /** Give the OpenGL texture id (oTextureId) and the texture coordinate of the element
      pointed by the sprite id iId with the type iType.
      @param iId The sprite id.
      @param iType The type of the element.
      @param oTextureId The OpenGL texture id.
      @param oTexCoordBL The bottom-left texture coordinates.
      @param oTexCoordTL The top-left texture coordinates.
      @param oTexCoordTR The top-right texture coordinates.
      @param oTexCoordBR The bottom-right texture coordinates.
      */
      void getTexture(const unsigned int & iId, const textureType & iType, unsigned int & oTextureId, float2 & oTexCoordBL, float2 & oTexCoordTL,
                      float2 & oTexCoordTR, float2 & oTexCoordBR) const;

      /** Load a texture as an OpenGL Texture
      @param iFileTexture The file of the texture. See ITextureReader to see which extensions are supported.
      @param iFileDescription The description's file associated to the texture. By default, the function
      takes the associated .desc file of the texture. Example : toto.bmp, toto.desc (functionnality not yet implemented)
      @see ITextureReader
      */
      void loadTexture(const textureType iTextureType, const std::string & iFileTexture, const std::string & iFileDescription);


};

#endif // TEXTUREMANAGER_H
